package com.iwomy.envpro.platform.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.iwomy.envpro.common.data.tenant.TenantContextHolder;
import com.iwomy.envpro.platform.VO.AlarmLoggingStatusVO;
import com.iwomy.envpro.platform.VO.EquipmentGroupingStatisticsVO;
import com.iwomy.envpro.platform.VO.LargeScreenVO;
import com.iwomy.envpro.platform.entity.AlarmLoggingEntity;
import com.iwomy.envpro.platform.mapper.LargeScreenMapper;
import com.iwomy.envpro.platform.service.AirMonitorEquipmentService;
import com.iwomy.envpro.platform.service.AlarmLoggingService;
import com.iwomy.envpro.platform.service.LargeScreenService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 数据大屏
 *
 * @author pig
 * @date 2023-09-26 14:57:17
 */
@Service
public class LargeScreenServiceImpl  implements LargeScreenService {

	@Resource
	private AirMonitorEquipmentService airMonitorEquipmentService;
	@Resource
	private AlarmLoggingService alarmLoggingService;
	@Resource
	private LargeScreenMapper largeScreenMapper;

	@Override
	public List<LargeScreenVO> equipmentGroupingStatistics() {
		return largeScreenMapper.equipmentGroupingStatistics();
	}

	@Override
	public List<LargeScreenVO> groupAlarmStatistics() {
		return largeScreenMapper.groupAlarmStatistics();
	}

	@Override
	public AlarmLoggingStatusVO alarmStatistics() {


		long falseAlarm = alarmLoggingService.count(Wrappers.<AlarmLoggingEntity>lambdaQuery().eq(AlarmLoggingEntity::getEventStatus, 30));
		long untreated = alarmLoggingService.count(Wrappers.<AlarmLoggingEntity>lambdaQuery().eq(AlarmLoggingEntity::getEventStatus, 10));
		long processed = alarmLoggingService.count(Wrappers.<AlarmLoggingEntity>lambdaQuery().eq(AlarmLoggingEntity::getEventStatus, 20));


		AlarmLoggingStatusVO alarmLoggingStatusVO = new AlarmLoggingStatusVO();
		alarmLoggingStatusVO.setFalseAlarm(falseAlarm);
		alarmLoggingStatusVO.setUntreated(untreated);
		alarmLoggingStatusVO.setProcessed(processed);



		return alarmLoggingStatusVO;
	}

	@Override
	public List<LargeScreenVO> alarmTrendCurve() {
		return largeScreenMapper.alarmTrendCurve();
	}
}